package com.bckj.fastboot.paid.biz.infrastructure.repo;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bckj.fastboot.paid.api.entity.PayConfig;
import com.bckj.fastboot.paid.biz.domain.pay.repo.PayConfigRepository;
import com.bckj.fastboot.paid.biz.domain.pay.repo.PayMerchantConfigRepository;
import com.bckj.fastboot.paid.biz.infrastructure.mapper.PayConfigMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class PayConfigRepositoryImpl extends ServiceImpl<PayConfigMapper, PayConfig> implements PayConfigRepository {

    private final PayMerchantConfigRepository payMerchantConfigRepository;

    @Override
    public PayConfig getByAppId(String appId) {
        PayConfig r = lambdaQuery().eq(PayConfig::getAppId, appId).one();
        if (r != null) {
            r.setPayMerchantConfig(payMerchantConfigRepository.getById(r.getPayMerchantConfigId()));
        }
        return r;
    }
}
